module.exports = Behavior({
  behaviors: [],
  properties: {
    xfield: {
      type: String,
      value: "",
    }
  },
  data: {
    myBehaviorData: {}
  },
  attached: function () {},
  methods: {
    myBehaviorMethod: function () {},
    diynavigateTo: function (ev) {
      var dataset = ev.currentTarget.dataset
      var item = dataset.item;
      if (!item) {
        return;
      }

      var app = getApp();
      var m = app.xc_sys_config.get_m()
      if (dataset.type == "pro" && !item.hasOwnProperty("appid") && item.id) {

        item.url = "/" + m + "/shop/pro/proinfo?id=" + item.id
        item.cid = 1
        if (dataset.activityid) {

          item.url += "&activityid=" + dataset.activityid
        }


        //item.url=""
      }
      // item.cid=6
      if (item.cid == 6) {
      

        if (item.url == 'phone') {
          wx.makePhoneCall({
            phoneNumber: item.val,
            success: function () {

            },
            fail: function () {

            }
          })
        } else {
          switch (this.data.type) {

            case "diyprolimit": {
              item.url = "/" + m + "/shop/activity/actlist?activityid=" + this.data.datasource.data.id
              //  item.url="/"+ m+"/shop/activity/actlist"
              item.cid = 1
              break;
            }
            case "phone": {
              wx.makePhoneCall({
                phoneNumber: item.val,
                success: function () {

                },
                fail: function () {

                }
              })
              break;
            }
          }
        }
        // this.data.type='phone'
        // item.val="13864845126"

      }
      app.xc_sys_config.router.diynavigateTo(item)
    },
    _navigateTo: function (url, model, para) {

      var urlpara = [];
      if (para) {
        var attrpara = para.split(",");
        for (var a in attrpara) {
          urlpara.push(attrpara[a] + "=" + model[attrpara[a]])
        }
        if (url.indexOf("?") < 0) {
          url = url + "?";
        } else {
          url = url + "&";
        }
        url += urlpara.join("&")
      }
      var app = getApp();
      app.xc_sys_config.router.navigateTo(url)
    }
  }
})